#ifndef __GLOBALRECIEVER_H__
#define __GLOBALRECIEVER_H__

#include "gwmessagetab.hpp"
#include "IMessageOperator.h"
#include "protonet.hpp"
#include "../NetMessageTab.h"
#include "global.pb.h"
#include "../Global/GlobalTab.h"

/**
*@file       GlobalReciever.h
*@brief      process message Global
*
*@author     graywind
*@version    1.0.0.0
*@data       2012/3/16
*/

///process message
class OnGlobal
{
public:
    ///@brief    process message
    ///param[in] op            operator type
    ///param[in] session_id    identifier of session
    ///param[in] pMsgBuffer    message buffer
    ///param[in] msg_bytes     byte length of message buffer
    ///retval    void
    static void OnMapping(IMessageOperator* op, int session_id, void* pMsgBuffer, unsigned long msg_bytes)
    {
        //TODO
        GlobalMain mainMsg;
        if(ProtoNet<GlobalMain>::CreateFromBytes(mainMsg, pMsgBuffer, msg_bytes))
        {
            GlobalProcessor::ProcessMessage(op, session_id, (void*)mainMsg.subbuffer().c_str(), mainMsg.subid(), mainMsg.subbuffer().length() > 0 ? mainMsg.subbuffer().length() : 0);
        }
    }
};

///[message group]  [message type]  [function table] [handler]
RegisterMessageTab(NetMessageTypes, Global, NetMessageTab, OnGlobal);
#endif
